/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.manager;

import com.google.inject.Inject;
import com.wideplay.warp.persist.Transactional;
import exatrez.dao.SeverityCodeDAO;
import exatrez.dao.StatusRemarkCodeDAO;
import exatrez.model.SeverityCode;
import exatrez.model.StatusRemarkCode;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author wan.fairul
 */
public class RemarkManager {

    @Inject
    protected com.google.inject.Provider<Session> sessionProvider;
    @Inject
    private StatusRemarkCodeDAO statusRemarkCodeDAO;

    @Transactional
    public void saveOrUpdate(StatusRemarkCode statusRemarkCode) {
        statusRemarkCodeDAO.saveOrUpdate(statusRemarkCode);
    }

    @Transactional
    public void deleteSeverity(StatusRemarkCode statusRemarkCode) {
        statusRemarkCodeDAO.delete(statusRemarkCode);
    }
    
    public StatusRemarkCode findRemarkCode(String statusRemarkName) {
        String query = "SELECT a FROM StatusRemarkCode a WHERE a.statusRemarkName = :statusRemarkName  ";
        Query q = sessionProvider.get().createQuery(query);
        q.setString("statusRemarkName", statusRemarkName);
        return (StatusRemarkCode) q.uniqueResult();
    }
    
     public StatusRemarkCode findNotRemarkCode(String statusRemarkCodeId,String statusRemarkName) {
        String query = "SELECT a FROM StatusRemarkCode a WHERE a.statusRemarkCodeId != :statusRemarkCodeId and a.statusRemarkName = :statusRemarkName  ";
        Query q = sessionProvider.get().createQuery(query);
        q.setString("statusRemarkCodeId", statusRemarkCodeId);
        q.setString("statusRemarkName", statusRemarkName);
        return (StatusRemarkCode) q.uniqueResult();
    }
    
     public List<StatusRemarkCode> findAllVesselGroup() {
        String query = "SELECT a FROM StatusRemarkCode a WHERE a.statusRemarkCodeId is not null  ";
        Query q = sessionProvider.get().createQuery(query);
        return q.list();
    }

    public StatusRemarkCodeDAO getStatusRemarkCodeDAO() {
        return statusRemarkCodeDAO;
    }

    public void setStatusRemarkCodeDAO(StatusRemarkCodeDAO statusRemarkCodeDAO) {
        this.statusRemarkCodeDAO = statusRemarkCodeDAO;
    }

  

  
}
